.PHONY: test clean compile stdin zip

default: all

all: javacc compile Scanner.class test

Scanner.class: Scanner.jj Scanner.java
	javacc Scanner.jj
	javac -source 1.4  *.java
	java -classpath . TestScanner


testfile: testfile Scanner.class
	java -classpath . TestScanner $<

stdin:
	java -classpath . TestScanner
	
compile:
	javac -source 1.4  *.java
	
javacc: Scanner.jj 
	javacc Scanner.jj
	
run:
	java -classpath . TestScanner
	

CharacterToken.class:
	javac -source 1.4  CharacterToken.java
TestScanner.class:
	javac -source 1.4  TestScanner.java
StringToken.class: StringToken.java
	java -source 1.4 $<
NumberToken.class: NumberToken.java
	java -source 1.4 $<
clean:
	@rm -f *.class
	@rm -f *.zip
	@rm -f *~

# using the arsenal of tests provided by the teacher in Test directory
TESTDIR=Test
test: 
	@for testfile in $(TESTDIR)/*.hl; do \
	    root=`echo $$testfile | sed -e 's|Test/test||' | sed -e 's|\.hl||'` ;\
	    echo $$root ;\
	    java -classpath . TestScanner $$testfile > Test/my$$root ;\
	    diff $(TESTDIR)/my$$root $(TESTDIR)/results$$root ;\
	done

zip:
	#@zip -r  assignment1_marclijour.zip  . -x \*\*/.svn/* Test/* Test[/] [.]svn/* .project *~
	@zip -r  assignment1_marclijour.zip  . -x \*\*/.svn/* [.]svn/* .project *~
